package com.lxf.clouduser.controller;

import com.alibaba.fastjson.JSONObject;
import com.lxf.clouduser.service.GroupService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;

/**
 * @author 罗兴发
 * @data 2025/6/13 17:00
 * @description：群聊-控制层
 */
@RestController
@CrossOrigin  //跨域
@RequestMapping("/v1")
@Slf4j
public class GroupController {

    @Resource
    GroupService groupService;

    /**
     * 根据群号或群名称搜索群组详情信息
     * @param json
     * @return
     */
    @PostMapping("/getGroupByGroupIdAndName")
    public String getGroupByGroupIdAndName(@RequestBody JSONObject json){
        return groupService.getGroupByGroupIdAndName(json);
    }

    /**
     * 根据群号获取群组详情信息
     * @param json
     * @return
     */
    @PostMapping("/getGroupInfoByGroupId")
    public String getGroupInfoByGroupId(@RequestBody JSONObject json){
        return groupService.getGroupInfoByGroupId(json);
    }

    /**
     * 根据群号修改群组详情信息
     * @param json
     * @return
     */
    @PostMapping("/updateGroupByGroupId")
    public String updateGroupByGroupId(@RequestBody JSONObject json,HttpServletRequest request){
        return groupService.updateGroupByGroupId(json,request);
    }
}
